// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using System;
using System.Linq;
using Elastic.Clients.Elasticsearch.Serialization;

namespace Elastic.Clients.Elasticsearch.Cluster;

public sealed partial class PutClusterSettingsRequestParameters : Elastic.Transport.RequestParameters
{
	/// <summary>
	/// <para>
	/// Return settings in flat format (default: false)
	/// </para>
	/// </summary>
	public bool? FlatSettings { get => Q<bool?>("flat_settings"); set => Q("flat_settings", value); }

	/// <summary>
	/// <para>
	/// Explicit operation timeout for connection to master node
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("master_timeout"); set => Q("master_timeout", value); }

	/// <summary>
	/// <para>
	/// Explicit operation timeout
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("timeout"); set => Q("timeout", value); }
}

/// <summary>
/// <para>
/// Update the cluster settings.
/// </para>
/// <para>
/// Configure and update dynamic settings on a running cluster.
/// You can also configure dynamic settings locally on an unstarted or shut down node in <c>elasticsearch.yml</c>.
/// </para>
/// <para>
/// Updates made with this API can be persistent, which apply across cluster restarts, or transient, which reset after a cluster restart.
/// You can also reset transient or persistent settings by assigning them a null value.
/// </para>
/// <para>
/// If you configure the same setting using multiple methods, Elasticsearch applies the settings in following order of precedence: 1) Transient setting; 2) Persistent setting; 3) <c>elasticsearch.yml</c> setting; 4) Default setting value.
/// For example, you can apply a transient setting to override a persistent setting or <c>elasticsearch.yml</c> setting.
/// However, a change to an <c>elasticsearch.yml</c> setting will not override a defined transient or persistent setting.
/// </para>
/// <para>
/// TIP: In Elastic Cloud, use the user settings feature to configure all cluster settings. This method automatically rejects unsafe settings that could break your cluster.
/// If you run Elasticsearch on your own hardware, use this API to configure dynamic cluster settings.
/// Only use <c>elasticsearch.yml</c> for static cluster settings and node settings.
/// The API doesn’t require a restart and ensures a setting’s value is the same on all nodes.
/// </para>
/// <para>
/// WARNING: Transient cluster settings are no longer recommended. Use persistent cluster settings instead.
/// If a cluster becomes unstable, transient settings can clear unexpectedly, resulting in a potentially undesired cluster configuration.
/// </para>
/// </summary>
[System.Text.Json.Serialization.JsonConverter(typeof(Elastic.Clients.Elasticsearch.Cluster.Json.PutClusterSettingsRequestConverter))]
public sealed partial class PutClusterSettingsRequest : Elastic.Clients.Elasticsearch.Requests.PlainRequest<Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestParameters>
{
#if NET7_0_OR_GREATER
	public PutClusterSettingsRequest()
	{
	}
#endif
#if !NET7_0_OR_GREATER
	public PutClusterSettingsRequest()
	{
	}
#endif
	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	internal PutClusterSettingsRequest(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel sentinel)
	{
		_ = sentinel;
	}

	internal override Elastic.Clients.Elasticsearch.Requests.ApiUrls ApiUrls => Elastic.Clients.Elasticsearch.Requests.ApiUrlLookup.ClusterPutSettings;

	protected override Elastic.Transport.HttpMethod StaticHttpMethod => Elastic.Transport.HttpMethod.PUT;

	internal override bool SupportsBody => true;

	internal override string OperationName => "cluster.put_settings";

	/// <summary>
	/// <para>
	/// Return settings in flat format (default: false)
	/// </para>
	/// </summary>
	public bool? FlatSettings { get => Q<bool?>("flat_settings"); set => Q("flat_settings", value); }

	/// <summary>
	/// <para>
	/// Explicit operation timeout for connection to master node
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("master_timeout"); set => Q("master_timeout", value); }

	/// <summary>
	/// <para>
	/// Explicit operation timeout
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("timeout"); set => Q("timeout", value); }

	/// <summary>
	/// <para>
	/// The settings that persist after the cluster restarts.
	/// </para>
	/// </summary>
	public System.Collections.Generic.IDictionary<string, object>? Persistent { get; set; }

	/// <summary>
	/// <para>
	/// The settings that do not persist after the cluster restarts.
	/// </para>
	/// </summary>
	public System.Collections.Generic.IDictionary<string, object>? Transient { get; set; }
}

/// <summary>
/// <para>
/// Update the cluster settings.
/// </para>
/// <para>
/// Configure and update dynamic settings on a running cluster.
/// You can also configure dynamic settings locally on an unstarted or shut down node in <c>elasticsearch.yml</c>.
/// </para>
/// <para>
/// Updates made with this API can be persistent, which apply across cluster restarts, or transient, which reset after a cluster restart.
/// You can also reset transient or persistent settings by assigning them a null value.
/// </para>
/// <para>
/// If you configure the same setting using multiple methods, Elasticsearch applies the settings in following order of precedence: 1) Transient setting; 2) Persistent setting; 3) <c>elasticsearch.yml</c> setting; 4) Default setting value.
/// For example, you can apply a transient setting to override a persistent setting or <c>elasticsearch.yml</c> setting.
/// However, a change to an <c>elasticsearch.yml</c> setting will not override a defined transient or persistent setting.
/// </para>
/// <para>
/// TIP: In Elastic Cloud, use the user settings feature to configure all cluster settings. This method automatically rejects unsafe settings that could break your cluster.
/// If you run Elasticsearch on your own hardware, use this API to configure dynamic cluster settings.
/// Only use <c>elasticsearch.yml</c> for static cluster settings and node settings.
/// The API doesn’t require a restart and ensures a setting’s value is the same on all nodes.
/// </para>
/// <para>
/// WARNING: Transient cluster settings are no longer recommended. Use persistent cluster settings instead.
/// If a cluster becomes unstable, transient settings can clear unexpectedly, resulting in a potentially undesired cluster configuration.
/// </para>
/// </summary>
public readonly partial struct PutClusterSettingsRequestDescriptor
{
	internal Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequest Instance { get; init; }

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public PutClusterSettingsRequestDescriptor(Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequest instance)
	{
		Instance = instance;
	}

	public PutClusterSettingsRequestDescriptor()
	{
		Instance = new Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequest(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
	}

	public static explicit operator Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor(Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequest instance) => new Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor(instance);
	public static implicit operator Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequest(Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor descriptor) => descriptor.Instance;

	/// <summary>
	/// <para>
	/// Return settings in flat format (default: false)
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor FlatSettings(bool? value = true)
	{
		Instance.FlatSettings = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// Explicit operation timeout for connection to master node
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor MasterTimeout(Elastic.Clients.Elasticsearch.Duration? value)
	{
		Instance.MasterTimeout = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// Explicit operation timeout
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor Timeout(Elastic.Clients.Elasticsearch.Duration? value)
	{
		Instance.Timeout = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The settings that persist after the cluster restarts.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor Persistent(System.Collections.Generic.IDictionary<string, object>? value)
	{
		Instance.Persistent = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The settings that persist after the cluster restarts.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor Persistent()
	{
		Instance.Persistent = Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfStringObject.Build(null);
		return this;
	}

	/// <summary>
	/// <para>
	/// The settings that persist after the cluster restarts.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor Persistent(System.Action<Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfStringObject>? action)
	{
		Instance.Persistent = Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfStringObject.Build(action);
		return this;
	}

	public Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor AddPersistent(string key, object value)
	{
		Instance.Persistent ??= new System.Collections.Generic.Dictionary<string, object>();
		Instance.Persistent.Add(key, value);
		return this;
	}

	/// <summary>
	/// <para>
	/// The settings that do not persist after the cluster restarts.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor Transient(System.Collections.Generic.IDictionary<string, object>? value)
	{
		Instance.Transient = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The settings that do not persist after the cluster restarts.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor Transient()
	{
		Instance.Transient = Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfStringObject.Build(null);
		return this;
	}

	/// <summary>
	/// <para>
	/// The settings that do not persist after the cluster restarts.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor Transient(System.Action<Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfStringObject>? action)
	{
		Instance.Transient = Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfStringObject.Build(action);
		return this;
	}

	public Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor AddTransient(string key, object value)
	{
		Instance.Transient ??= new System.Collections.Generic.Dictionary<string, object>();
		Instance.Transient.Add(key, value);
		return this;
	}

	[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
	internal static Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequest Build(System.Action<Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor>? action)
	{
		if (action is null)
		{
			return new Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequest(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
		}

		var builder = new Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor(new Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequest(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance));
		action.Invoke(builder);
		return builder.Instance;
	}

	public Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor ErrorTrace(bool? value)
	{
		Instance.ErrorTrace = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor FilterPath(params string[]? value)
	{
		Instance.FilterPath = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor Human(bool? value)
	{
		Instance.Human = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor Pretty(bool? value)
	{
		Instance.Pretty = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor SourceQueryString(string? value)
	{
		Instance.SourceQueryString = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor RequestConfiguration(Elastic.Transport.IRequestConfiguration? value)
	{
		Instance.RequestConfiguration = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.Cluster.PutClusterSettingsRequestDescriptor RequestConfiguration(System.Func<Elastic.Transport.RequestConfigurationDescriptor, Elastic.Transport.IRequestConfiguration>? configurationSelector)
	{
		Instance.RequestConfiguration = configurationSelector.Invoke(Instance.RequestConfiguration is null ? new Elastic.Transport.RequestConfigurationDescriptor() : new Elastic.Transport.RequestConfigurationDescriptor(Instance.RequestConfiguration)) ?? Instance.RequestConfiguration;
		return this;
	}
}